package cn.java.Concurrency;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author 小石潭记
 * @date 2021/12/19 10:34
 * @Description: ${todo}
 */
public class Test2 {
    public static void main(String[] args) throws InterruptedException {
        ThreadPoolExecutor executor = new ThreadPoolExecutor(2, 3,
                5L, TimeUnit.SECONDS, new LinkedBlockingQueue<>());
        executor.setRejectedExecutionHandler(new MyRejectedExecutionHandler());
        executor.submit(new MyRunnable1("A"));
        executor.submit(new MyRunnable1("B"));
        executor.submit(new MyRunnable1("C"));
        executor.shutdown();
        executor.submit(new MyRunnable1("D"));
        executor.submit(new MyRunnable1("E"));
    }

}
